package com.woniuxy.controller;

import com.woniuxy.entity.DrugDistribution;
import com.woniuxy.service.IDrugDistributionService;
import com.woniuxy.util.PageParam;
import com.woniuxy.util.ResponseData;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * 药品发放列表
 */
@RestController
@RequestMapping("/drugDistribution")
public class DrugDistributionController {


    @Resource
    private IDrugDistributionService drugDistributionService;

    @PostMapping("/queryDrugDistribution")
    public ResponseData<?> queryDrugDistribution(@RequestBody PageParam<DrugDistribution> pageParam){
        Assert.notNull(pageParam,"pageParam is not null");
        return drugDistributionService.queryDrugDistribution(pageParam);
    }


    @GetMapping("/queryDrug/{ppNo}")
    public ResponseData<?> queryDrugDetail(@PathVariable("ppNo") String ppNo){
        Assert.notNull(ppNo,"ppNo is not null");
        return drugDistributionService.queryDrugDetail(ppNo);
    }


    @GetMapping("/updateDrugStatus/{id}")
    public ResponseData<?> updateDrugStatus(@PathVariable("id")Integer id){
        Assert.notNull(id,"id is not null");
        return drugDistributionService.updateDrugDistribution(id);
    }

    @GetMapping("queryMDSByPpNo/{id}")
    public ResponseData<?> queryMDSByPpNo(@PathVariable("id") Integer id){
        return drugDistributionService.queryMDSByPpNo(id);
    }
}
